﻿@using LibraryHub.Core.Models.User
@using LibraryHub.Core.Helpers
@model FindModel

@{
    ViewBag.Title = "Найденные библиотекари";
}

<h2>@ViewBag.Title</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Библиотекарь</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.CurrentSearch.Login, "Логин")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.CurrentSearch.Login)
            @Html.ValidationMessageFor(model => model.CurrentSearch.Login)
        </div>
        
        <div class="editor-label">
            @Html.LabelFor(model => model.CurrentSearch.FullName, "Полное имя")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.CurrentSearch.FullName)
            @Html.ValidationMessageFor(model => model.CurrentSearch.FullName)
        </div>

        <p>
            <input type="submit" value="Искать библиотекаря" />
        </p>
    </fieldset>
}

<table>
    <tr>
        <th>
            Логин
        </th>
        <th>
            Полное имя
        </th>
        <th>
            Роль //TODO: remove, debug
        </th>
        <th></th>
    </tr>

@foreach (var item in Model.Users) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Login)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.FullName)
        </td>
        <td>
            @item.Role.GetDescription()
        </td>
        <td>
            @Html.ActionLink("Редактировать", "Edit", new { id = item.Id }) |
            @Html.ActionLink("Подробно", "Details", new { id = item.Id }) |
            @Html.ActionLink("Удалить", "Delete", new { id = item.Id })
        </td>
    </tr>
}

</table>
